package com.hsav.kcxb.view;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.hsav.kcxb.R;
import com.hsav.kcxb.adapter.GiftListAdapter;
import com.hsav.kcxb.bean.GiftItemBean;

import java.util.ArrayList;

/**
 * Created by zhao on 2017/2/5.
 */

public class GiftItemView extends LinearLayout{

    private final Context mContext;
    private RecyclerView mRecyclerView;

    public GiftItemView(Context context) {
        this(context,null);
    }

    public GiftItemView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public GiftItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();

    }

    private void initView() {
        View rootView = LayoutInflater.from(mContext).inflate(R.layout.frg_gift_layout,this);
        mRecyclerView = (RecyclerView)rootView.findViewById(R.id.list_gift);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext,2,GridLayoutManager.HORIZONTAL,false);
        mRecyclerView.setLayoutManager(gridLayoutManager);
        ArrayList<GiftItemBean> giftItemList = new ArrayList<>();
        giftItemList.add(new GiftItemBean(0,"null","haha",344));
        giftItemList.add(new GiftItemBean(2,"null","hahah",445));
        giftItemList.add(new GiftItemBean(3,"null","dgfdf",234));
        giftItemList.add(new GiftItemBean(0,"null","haha",344));
        giftItemList.add(new GiftItemBean(2,"null","hahah",445));
        giftItemList.add(new GiftItemBean(3,"null","dgfdf",234));
        giftItemList.add(new GiftItemBean(0,"null","haha",344));
        giftItemList.add(new GiftItemBean(2,"null","hahah",445));
        giftItemList.add(new GiftItemBean(3,"null","dgfdf",234));
        giftItemList.add(new GiftItemBean(0,"null","haha",344));
        giftItemList.add(new GiftItemBean(2,"null","hahah",445));
        giftItemList.add(new GiftItemBean(3,"null","dgfdf",234));
        giftItemList.add(new GiftItemBean(0,"null","haha",344));
        giftItemList.add(new GiftItemBean(2,"null","hahah",445));
        giftItemList.add(new GiftItemBean(3,"null","dgfdf",234));
        GiftListAdapter giftListAdapter = new GiftListAdapter(mContext);
        mRecyclerView.setAdapter(giftListAdapter);
    }
}
